local weishi = fk.CreateSkill{
  name = "wk_heg__weishi",
}

Fk:loadTranslationTable{
  ["wk_heg__weishi"] = "危示",
  [":wk_heg__weishi"] = "与你势力相同的角色成为【杀】的唯一目标后，你可以令其观看你所有手牌并获得其中一张（若其为你则跳过），"..
    "此牌结算后若未对其造成过伤害，你重铸所有手牌。",
}

local H = require "packages.ol_hegemony.util"
local HG = require "packages.new_heg_diy_my.util"

weishi:addEffect(fk.TargetConfirmed, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return H.compareKingdomWith(target, player) and player:hasSkill(self) and not player:isKongcheng() and #data:getAllTargets() == 1
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if target ~= player then
      local cards = room:askToChooseCardsAndChoice(target, {
        cards = player:getCardIds(Player.Hand),
        min_num = 1,
        max_num = 1,
        skill_name = weishi.name,
      })
      if #cards == 0 then return end
      room:obtainCard(target, cards, false, fk.ReasonPrey, player, weishi.name)
    end
    data.card.extra_data = data.card.extra_data or {}
    data.card.extra_data.wk_heg__weishi = target
  end
})

weishi:addEffect(fk.CardUseFinished, {
  is_delay_effect = true,
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    local table_mark = player:getTableMark("wk_heg__weishi")
    return player:hasSkill(weishi.name) and data.card.extra_data and data.card.extra_data.wk_heg__weishi and
      (data.damageDealt == nil or data.damageDealt[data.card.extra_data.wk_heg__weishi] == nil or data.damageDealt[data.card.extra_data.wk_heg__weishi  ] == 0)
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = player:getCardIds(Player.Hand)
    room:recastCard(cards, player, weishi.name)
  end
})

return weishi